package com.fenghao.subject.infra.basic.service.impl;

import com.fenghao.subject.infra.basic.entity.SubjectInfo;
import com.fenghao.subject.infra.basic.mapper.SubjectInfoDao;
import com.fenghao.subject.infra.basic.service.SubjectInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * SubjectInfoServiceImpl
 */
@Service
public class SubjectInfoServiceImpl implements SubjectInfoService {
    @Resource
    private SubjectInfoDao subjectInfoDao;

    /**
     * 通过ID查询单条数据
     */
    @Override
    public SubjectInfo queryById(Long id) {
        return this.subjectInfoDao.queryById(id);
    }


    /**
     * 新增数据
     */
    @Override
    public int insert(SubjectInfo subjectInfo) {
        return subjectInfoDao.insert(subjectInfo);
    }

    /**
     * 修改数据
     */
    @Override
    public SubjectInfo update(SubjectInfo subjectInfo) {
        this.subjectInfoDao.update(subjectInfo);
        return this.queryById(subjectInfo.getId());
    }

    /**
     * 通过主键删除数据
     */
    @Override
    public boolean deleteById(Long id) {
        return this.subjectInfoDao.deleteById(id) > 0;
    }
}
